<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>       
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="${_resources}/logo.png"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">                                            
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />  
    <title>章节内容</title>	
	<script type="text/javascript" src="${_resources}jq/jquery-1.8.3.min.js"></script>
	<script>
	var id = "${sectionId}";
	var status =false;
	var TANGER_OCX_OBJ;
	function init(){
		TANGER_OCX_OBJ=document.getElementById("TANGER_OCX");
		TANGER_OCX_OBJ.activate(true);
		
		 TANGER_OCX_OBJ.SetReadOnly(true); 
		 //允许或禁止文件－>新建菜单
		 TANGER_OCX_OBJ.FileNew = false;
		 //允许或禁止文件－>打开菜单
		 TANGER_OCX_OBJ. FileOpen  = true;
		 //允许或禁止文件－>关闭菜单
		 TANGER_OCX_OBJ.FileClose = false;
		 //允许或禁止文件－>保存菜单
		 TANGER_OCX_OBJ.FileSave = false;
		 //允许或禁止文件－>另存为菜单
		 TANGER_OCX_OBJ.FileSaveAs = false;
		 //允许或禁止文件－>打印菜单
		 TANGER_OCX_OBJ.FilePrint = false;
		 //允许或禁止文件－>打印预览菜单
		 TANGER_OCX_OBJ.FilePrintPreview = false;
		 //允许或禁止文件－>页面设置
		 TANGER_OCX_OBJ.FilePageSetup = false;
		 //允许或禁止文件－>属性
		 TANGER_OCX_OBJ.FileProperties = false;
		 TANGER_OCX_OBJ.Toolbars = false;
		 TANGER_OCX_OBJ.Menubar = false;	
		 getStatus();
		 if(getStatus()==true||getStatus()=='true'){
			 var url = "${_baseUrl}/sectioNtkoContentController/openSectionContent.do?sectionId="+id;
		    	TANGER_OCX_OBJ.BeginOpenFromURL(url);
				// 文档发布之后，通过NTKO打开应为只读模式			 
		    	/* TANGER_OCX_OBJ.BeginOpenFromURL(url,true,true); */
		 }else{
			 var url = "${_baseUrl}/documentTemplateController/previewTemplateDocument.do?id=3d542c1d1ed94b568969c7db0e801a0e";
		    	TANGER_OCX_OBJ.BeginOpenFromURL(url); 
		 }		 	 
			
		 TANGER_OCX_OBJ.IsStrictNoCopy = false;
		 
	}
	
	function  close(){
		 TANGER_OCX_OBJ.activate(false);
	}
	
	function getStatus(){		
		var path="${_baseUrl}/sectioNtkoContentController/judgeSectionContent.do?sectionId="+id;
		$.ajax({
			cache:false,//是否缓存
			type:"POST",//提交方式
			url:path,
			//data:$("form").serialize(),
			async:false,//是否异步
			dataType:"json",
			error:function(request){//错误时
			 	
			},
			success:function(data){	
				if(data.message=="1"){
					status =true;
				}else{
					status=false;
				}
			}
	 	});
	 	return status;
	} 
	
	function openFile(){
		TANGER_OCX_OBJ.ActiveDocument.Protect(3,false,"kd");//保护文档
	}
</script>
  </head>
  
  <body onload="init();">
  
   <form action="" id="myFile" enctype="multipart/form-data" method="post">
   <script type="text/javascript" src="${_officecontrol}ntkoofficecontrol.js"></script>
   <script type="text/javascript" for="TANGER_OCX" event="OnDocumentOpened(file,doc)"> openFile();</script>
   <!-- <script type="text/javascript" for="TANGER_OCX" event="OnFileCommand(cmd,canceled)">saveFile();</script>  -->
 </form> 
  </body>
</html>
